package com.study.example.gameserver.module.scene.bt.monitor;

import com.sparrow.common.ai.behaviortree.BehaviorContext;
import com.sparrow.common.ai.behaviortree.monitor.BTMonitor;
import com.sparrow.common.ai.behaviortree.task.BehaviorTask;
import com.sparrow.common.ai.behaviortree.task.impl.ConditionTask;
import com.sparrow.common.util.PropertiesUtil;
import com.study.example.gameserver.module.scene.entity.impl.Monster;
import org.springframework.stereotype.Component;

@Component
public class DebugBTMonitor implements BTMonitor {
    private long monsterId = PropertiesUtil.autoReloadLong("bt.monitor.monster.id", (val) -> monsterId = val, 0L);

    @Override
    public void onEnterTick(BehaviorContext context, BehaviorTask behaviorTask) {
        if (monsterId > 0L) {
            Monster monster = context.getOwner();
            if (monster.getId() == monsterId) {
                System.out.println("onEnterTick:" + behaviorTask.toString());
            }
        }
    }

    @Override
    public void checkCondition(BehaviorContext context, ConditionTask conditionTask, boolean value) {
        if (monsterId > 0L) {
            Monster monster = context.getOwner();
            if (monster.getId() == monsterId) {
                System.out.println("checkCondition:" + conditionTask.toString() + " returnValue=" + value);
            }
        }
    }
}
